package com.hr.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hr.dao.ProductCategoryDao;
import com.hr.entity.ProductGategory;
import com.hr.util.EncodeUtil;

public class DoProductClassUpdateServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        EncodeUtil.encode(req);
        int id = Integer.parseInt(req.getParameter("id"));
        int fid = Integer.parseInt(req.getParameter("parentId"));
        String name = req.getParameter("className");
        ProductGategory pc;
        if (fid == 0) {
            pc = new ProductGategory(id, name, 0);
        } else {
            pc = new ProductGategory(id, name, fid);
        }
        ProductCategoryDao.update(pc);
        resp.sendRedirect("productClass");
    }
}
